package edu.cuit.canary.admin.controller;

import edu.cuit.canary.commons.response.ResponseResult;
import edu.cuit.canary.core.service.SysUserService;
import edu.cuit.canary.entity.dto.SysUserDto;
import edu.cuit.canary.entity.po.SysUser;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/sys-users")
@Tag(name = "系统用户API文档")
public class SysUserRestController {
    @Resource private SysUserService service;

    @Operation(summary = "添加系统用户")
    @PostMapping
    public ResponseResult save(@RequestBody SysUser user){
        return service.save(user) ? ResponseResult.ok() : ResponseResult.fail("添加系统用户失败");
    }

    @Operation(summary = "系统用户分页列表")
    @Parameter(description = "查询参数")
    @GetMapping
    public ResponseResult list(SysUserDto parameter){
        return ResponseResult.ok(service.list(parameter));
    }
}
